package com.skyworthclub.competition.beans;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.IdType;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author li
 * @since 2018-10-15
 */
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@TableName("tbl_comment")
public class Comment extends Model<Comment> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "comment_id", type = IdType.AUTO)
    private Integer commentId;
    private LocalDateTime commentTime;
    @NotEmpty
    private String commentContent;
    @NotNull
    private Integer userId;
    @NotNull
    private Integer matchId;
    private Integer parentId;
    private String replyTo;
    /**
     * 子评论
     */
    @TableField(exist = false)
    private List<Comment> childComments;

    /**
     * 评论者用户对象
     */
    @TableField(exist = false)
    private User commentUser;


    @Override
    protected Serializable pkVal() {
        return this.commentId;
    }

}
